<?php
$adminList = "";
$obj = "\$object_$class";
$Uclass = strtoupper($class);
$colspan = count($var)+1;

$yuiFields = "";

$rowData = "";
$postData = "var postData = '';".$CR;
$colDef = "";
for ($i=0;$i<count($var);$i++){
	$yuiFields .= "'".$var[$i]["name"]."',";
	if ($var[$i]["name"]!="created_on" && $var[$i]["name"]!="updated_on"){
		$rowData .="\t\tvar row_".$var[$i]["name"]." = oArgs.record.getData('".$var[$i]["name"]."');".$CR;
		$postData .= "\t\t".'postData = postData + "'.$var[$i]["name"].'="+row_'.$var[$i]["name"]."+'&';$CR";
		$colDef .=$CR;
		$eop='';
		if ($var[$i]['type']=='INT'){
			$eop = ',editorOptions:{validator:YAHOO.widget.DataTable.validateNumber}';
		}
		$colDef .= $CR."\t\t\t".'{key:"'.$var[$i]["name"].'", label:"'.$var[$i]["title"].'", sortable:true, editor:"textbox"'.$eop.'},';
	}else{
		$colDef .= $CR."\t\t\t".'{key:"'.$var[$i]["name"].'", label:"'.$var[$i]["title"].'", sortable:true},';
	}
		
}
$yuiFields = rtrim($yuiFields,",");
$colDef = rtrim($colDef , ",");
$adminList .= <<<html
<?php
include("../../config/config.php");
?>
<html>
	<head>
		<title>category</title>
		<?php include(DIR_BASE."resource/includes/javascript/yui/assets/dataTableJS.php");?>
		<script type="text/javascript" src="<?php echo HTTP_BASE?>resource/includes/javascript/yui/assets/gb_dth.js"></script>
	</head>
	<body bgcolor="#FFFFFF" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" class=" yui-skin-sam">
		<div id="loading">Processing</div>
		<div style="width:800px;" align="center">
			<div id='header'><h1>LISTAGEM PAGINADA [$Uclass]</h1></div>
			<iframe id="yui-history-iframe" src="<?php echo HTTP_BASE?>resource/includes/javascript/yui/assets/blank.html"></iframe>
			<input id="yui-history-field" type="hidden">
			<div id="addNew" style="padding:5px;"></div>
			<div id="serverintegration"></div>
			<div id="cellediting"></div>
			<div id="dt-pag-nav"></div>
		</div>
		<script>
		// MY JSON URL:
		var urlFetch = '<?php echo HTTP_BASE?>/admin/$package/$class.list.json.php?';
		var urlSend = '<?php echo HTTP_BASE?>/admin/$package/$class.process.php?';
		// THE CONFIGURATION FOR THE TABLE DATA SOURCE
		var responseSchema = {
			resultsList: "records",
			fields: [$yuiFields],
			metaFields: {
				totalRecords: "totalRecords",
				paginationRecordOffset : "startIndex",
				sortKey: "sort",
				sortDir: "dir"
			}
		};
		// CONFIGURE THE SENDER
		var _saveCellEditor = function(oArgs,callBack){
			//alert(oArgs.record.getData("codigo"))
        	$("#loading").show();
        	$rowData
        	$postData
			var editRequest = YAHOO.util.Connect.asyncRequest('POST', urlSend, callBack, postData);
        };
		
		// Column definitions
		var myColumnDefs = [$colDef];
		function addNewItem(o){
			window.location.href="$class.edit.php";
		}
		
		// BUILD THE TABLE
		hisroty_DB(responseSchema,myColumnDefs);
		var oPushButton = new YAHOO.widget.Button({  
	                            label:"Adicionar $Uclass",  
	                            id:"pushbutton7",  
	                            container:"addNew" }); 
		oPushButton.on("click",addNewItem);
		</script>
	</body>
</html>
html;

?>

